{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "6e9fc27e",
   "metadata": {},
   "source": [
    "# 上周回顾\n",
    "\n",
    "## 1. 字典的三种创建\n",
    "\n",
    "## 2. 字典的性质\n",
    "\n",
    "> 1.无序的 \n",
    "> 2.key唯一 \n",
    "> 3.key不可变 \n",
    "\n",
    "# 本周学习内容\n",
    "\n",
    "# 1.字典的循环遍历\n",
    "\n",
    "# 2.字典的一般方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "52b81196",
   "metadata": {},
   "outputs": [],
   "source": [
    "info  = {\n",
    "    \"stu1801\":\"ZiQi\",\n",
    "    \"stu1802\":\"XiaoFeng\",\n",
    "    \"stu1803\":\"LiuYu\"\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "5710cd08",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stu1801': 'ZiQi', 'stu1802': 'XiaoFeng', 'stu1803': 'LiuYu'}"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "998dc135",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "stu1801\n",
      "stu1802\n",
      "stu1803\n"
     ]
    }
   ],
   "source": [
    "# A-1\n",
    "# i 指内容/y元素(item)\n",
    "for i in info:\n",
    "    print(i)\n",
    "    # i 只是key的值，并没有真正意义上获取到字典的完整信息"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "380cc65b",
   "metadata": {},
   "source": [
    "# 字典的循环 如何循环key:value  作为items输出\n",
    "for k,v in info.items():\n",
    "    print(k,v)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "527ee827",
   "metadata": {},
   "outputs": [],
   "source": [
    "#A-2\n",
    "# 实践1：学号的k去掉stu 然后输出新的字典\n",
    "new_info = {}\n",
    "\n",
    "for k,v in info.items():\n",
    "    # 字典的新增\n",
    "    new_info[k[3:]] = v.upper()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "0e6d6d63",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'1801': 'ZIQI', '1802': 'XIAOFENG', '1803': 'LIUYU'}"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_info"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
